<?php if (!defined('BASEPATH')) exit('Sorry, error.. :]');

    require_once('smarty/Smarty.class.php');
       
    class SmartyLib extends Smarty{
    
        var $_object_stack = array();
        var $_fr = array(); // used by foreach_row plugin
        var $_ctx = null;
        var $_fetchLevel = 0;
               
        function SmartyLib()
        {      
            parent::Smarty();
            $this->left_delimiter = '{';
            $this->right_delimiter =  '}';            
            $this->template_dir = BASEPATH.'../photosite/views';
            $this->compile_dir = BASEPATH.'../photosite/temp/templates_c/';
            $this->config_dir = BASEPATH.'../photosite/temp/configs/';
            $this->cache_dir = BASEPATH.'../photosite/temp/cache/';
			
			$this->register_function('run_block', 'smarty_func_run_block', true);
			
			function &fetch($resource_name, $cache_id = null, $compile_id = null, $display = false) {
				if($this->_fetchLevel == 1) {
					$oldOutputFilters = $this->_plugins['outputfilter'];
					$this->_plugins['outputfilter'] = array();
				}
				$this->_fetchLevel++;
				$result = parent::fetch($resource_name, $cache_id, $compile_id, $display);
				$this->_fetchLevel--;
				if(isset($oldOutputFilters))
					$this->_plugins['outputfilter'] = $oldOutputFilters;
				return $result;
			}
        }
    }

	function smarty_func_run_block($params, &$smarty) {
		print_r($params);
	}